package cn.xxstudy.visitshop.ui.activity.main.fragment.interview.viewmodel

import androidx.lifecycle.MutableLiveData
import cn.xxstudy.visitshop.network.ApiService
import cn.xxstudy.visitshop.network.data.Response
import cn.xxstudy.visitshop.network.repository.BaseRepository
import cn.xxstudy.visitshop.ui.activity.main.fragment.interview.model.InterviewData

/**
 * @author ：DELL on 2021/3/26 .
 * @packages ：cn.xxstudy.visitshop.ui.activity.main.fragment.interview.viewmodel .
 * TODO:
 */
class InterviewRepository : BaseRepository() {

    suspend fun interviewList(
        userId:String,
        interviewLiveData: MutableLiveData<ArrayList<InterviewData>>,
        failLiveData: MutableLiveData<String>
    ) {
        val request = request { ApiService.api().interviewList(userId) }
        if (request is Response.SUCCESS) {
            interviewLiveData.postValue(request.data.results)
        }
        if (request is Response.FAILED) {
            failLiveData.postValue(request.message)
        }
    }
}